<?php
/**
 * The Header for our theme.
 *
 * Displays all of the <head> section and everything up till <div id="main">
 *
 * @package WordPress
 * @subpackage ACFood4U
 * @since Twenty Ten 1.0
 */
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php
		/*
		 * Print the <title> tag based on what is being viewed.
		 */
		global $page, $paged;
	
		wp_title( '|', true, 'right' );
	
		// Add the blog name.
		bloginfo( 'name' );
	
		// Add the blog description for the home/front page.
		$site_description = get_bloginfo( 'description', 'display' );
		if ( $site_description && ( is_home() || is_front_page() ) )
			echo " | $site_description";
	
		// Add a page number if necessary:
		if ( $paged >= 2 || $page >= 2 )
			echo ' | ' . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) );
	
		?></title>
<link type="text/css" href="<?php bloginfo('template_url'); ?>/themes/base/jquery.ui.all.css" rel="stylesheet" />
<link href="<?php bloginfo('template_url'); ?>/css/acfood.css" rel="stylesheet" type="text/css" />
<!--[if IE7]>
<style media="all" type="text/css">
	.naviBox .searchArea .srchBtn {
		text-indent:-9999px;
        font-size:1px;
        margin:0;
        padding:0;
        text-align:right;
	}
</style>
<![endif]-->


<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
	var timeout         = 10000;
	var closetimer		= 0;
	var ddmenuitem      = 0;
	
	function jsddm_open()
	{	jsddm_canceltimer();
		jsddm_close();
		ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');}
	
	function jsddm_close()
	{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}
	
	function jsddm_timer()
	{	closetimer = window.setTimeout(jsddm_close, timeout);}
	
	function jsddm_canceltimer()
	{	if(closetimer)
		{	window.clearTimeout(closetimer);
			closetimer = null;}}
	
	$(document).ready(function()
	{	$('#jsddm > li').bind('mouseover', jsddm_open);
		$('#jsddm > li').bind('mouseout',  jsddm_timer);});
	
	document.onclick = jsddm_close;
</script>

<!-- main feature toggle --> 
<script type="text/javascript">

	$(document).ready(function() {
		// hides the slickbox as soon as the DOM is ready
		
		// (a little sooner than page load)
		$("#feature2").hide();
		$("#feature3").hide();
		
		$("#showFeature1").click(function() { 
			// hides matched elements if shown, shows if hidden
			$("#feature2, #feature3").fadeOut();
			$("#feature1").fadeIn();
		});
		
		$("#showFeature2").click(function() { 
			// hides matched elements if shown, shows if hidden
			$("#feature1, #feature3").fadeOut();
			$("#feature2").fadeIn();
		});
		
		$("#showFeature3").click(function() { 
			// hides matched elements if shown, shows if hidden
			$("#feature1, #feature2").fadeOut();
			$("#feature3").fadeIn();
		});
	
	});
	
	$(function() {
		$("#tabs").tabs();
	});
</script>

<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/ui/jquery.ui.tabs.js"></script>

<?php
	/* We add some JavaScript to pages with the comment form
	 * to support sites with threaded comments (when in use).
	 */
	if ( is_singular() && get_option( 'thread_comments' ) )
		wp_enqueue_script( 'comment-reply' );

	/* Always have wp_head() just before the closing </head>
	 * tag of your theme, or you will break many plugins, which
	 * generally use this hook to add elements to <head> such
	 * as styles, scripts, and meta tags.
	 */
	wp_head();
?>

</head>

<body <?php body_class(); ?>>
<div class="pageBG">
  <div class="mainContainer">
    <div class="header">
      <div class="angelescityfood"> <img src="<?php bloginfo('template_url'); ?>/images/angelescityfood4u.jpg" width="126" height="119" /> </div>
      <div class="adBox"> <a href="#"><img src="<?php bloginfo('template_url'); ?>/images/premiums/icon-batis.jpg" width="104" height="64" border="0" /></a> </div>
      <div class="adBox"> <a href="#"><img src="<?php bloginfo('template_url'); ?>/images/premiums/icon-citalian.jpg" width="104" height="64" border="0" /></a> </div>
      <div class="adBox"> <a href="#"><img src="<?php bloginfo('template_url'); ?>/images/premiums/icon-cottage.jpg" width="104" height="64" border="0" /></a> </div>
      <div class="adBox"> <a href="#"><img src="<?php bloginfo('template_url'); ?>/images/premiums/icon-phillies.jpg" width="104" height="64" border="0" /></a> </div>
      <div class="adBox"> <a href="#"><img src="<?php bloginfo('template_url'); ?>/images/premiums/icon-margaritastation.jpg" width="104" height="64" border="0" /></a> </div>
    </div>
    <div class="naviBox">
      <div>
        <ul id="jsddm">
          <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>
        </ul>
      </div>
      <div class="searchArea">
        <?php get_search_form(); ?>
      </div>
    </div>
    <!-- ==================== Feature article ==================== -->
              
	<?php
        $querystr = "
        SELECT wposts.* 
        FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
        WHERE wposts.ID = wpostmeta.post_id 
        AND wpostmeta.meta_key = 'mainFeature' 
        AND wpostmeta.meta_value = 'yes'
        AND wposts.post_status = 'publish' 
        AND wposts.post_type = 'post' 
        AND wposts.post_date < NOW() 
        ORDER BY wposts.post_date DESC LIMIT 3
        ";
        $featuredPost = $wpdb->get_results($querystr, OBJECT);
    ?>
    
	<div class="featureBox">
        <div class="mainFeature">
        	
            <!-- ==================== Image Feature article ==================== -->
              
              <?php if ($featuredPost): ?>
              <?php $divCtr = 0; ?>
              <?php foreach ($featuredPost as $post): ?>
              <?php setup_postdata($post); ?>
              <?php $divCtr++; ?>
              <?php if (get_post_meta($post->ID, "mainFeatureImage") !='') { ?>
              <a id="feature<?php echo $divCtr; ?>" href="<?php the_permalink(); ?>"><img src="<?php echo get_post_meta($post->ID, "mainFeatureImage", true); ?>" alt="<?php the_title(); ?> icon" width="759" height="198" border="0" /></a>
              <?php } ?>
              <?php endforeach; ?>
              <?php else : ?>
              <h2 class="center">Not Found</h2>
              <p>Sorry, tag --> featuredPost.</p>
              <?php endif; ?>
        </div>
        <div class="selectFeature">
        <!-- ==================== Icon Feature article ==================== -->
              
              <?php if ($featuredPost): ?>
              <?php $divCtr2 = 0; ?>
              <?php foreach ($featuredPost as $post): ?>
              <?php setup_postdata($post); ?>
              <?php $divCtr2++; ?>
              <?php if (get_post_meta($post->ID, "mainFeatureIcon") !='') { ?>
              <div class="boxes"><a id="showFeature<?php echo $divCtr2; ?>" href="#"><img src="<?php echo get_post_meta($post->ID, "mainFeatureIcon", true); ?>" alt="<?php the_title(); ?>" width="180" height="47" border="0" /></a></div>
              <?php } ?>
              <?php endforeach; ?>
              <?php else : ?>
              <h2 class="center">Not Found</h2>
              <p>Sorry, tag --> featuredPost.</p>
              <?php endif; ?>
        </div>
    </div>
    <!-- end of feature box -->
